<!DOCTYPE html>

<html lang="zh-cn">

<head>
    <meta charset="utf-8">
    <title>Stroke</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <style>
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
</head>

<body>
    <script src="../assets/js/three.js"></script>
    <script src="../assets/js/controls/OrbitControls.js"></script>
    <script src="js/CopyShader.js"></script>
    <script src="js/EffectComposer.js"></script>
    <script src="js/RenderPass.js"></script>
    <script src="js/OutlinePass.js"></script>
    <script>
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

        var renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.autoClear = false;
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        var controls = new THREE.OrbitControls(camera, renderer.domElement);

        var amlight = new THREE.AmbientLight(0xffffff, 0.3);
        scene.add(amlight);

        var dirlight = new THREE.DirectionalLight(0xffffff, 0.7);
        dirlight.position.set(1, 1, 1);
        scene.add(dirlight);

        var geometry = new THREE.BoxGeometry(1, 1, 1);
        var material = new THREE.MeshPhongMaterial({ color: 0x00ff00 });
        var cube = new THREE.Mesh(geometry, material);
        scene.add(cube);

        camera.position.z = 5;

        var composer = new THREE.EffectComposer(renderer);

        var outlinePass = new THREE.OutlinePass({ x: renderer.domElement.width, y: renderer.domElement.height }, scene, camera, [cube]);
        outlinePass.clear = false;
        outlinePass.renderToScreen = true;
        composer.addPass(outlinePass);

        var animate = function () {
            requestAnimationFrame(animate);

            cube.rotation.x += 0.01;
            cube.rotation.y += 0.01;

            composer.render();
        };

        animate();
    </script>
</body>

</html>